package com.kchouse.common;

import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;

import com.kchouse.view.ProgressDialog;

import java.util.ArrayList;

/**
 * 共公基类Activity
 */
public class BaseActivity extends AppCompatActivity {

    public static ArrayList<Activity> listAct=new ArrayList<>();

    private ProgressDialog progressdialog;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        progressdialog = new ProgressDialog(this);
    }

    /**
     * 显示加载
     */
    public void showdialog()
    {
        progressdialog.show();
    }

    /**
     * 关闭加载
     */
    public void dismissdialog()
    {
        progressdialog.dismiss();
    }

    /**
     * 添加act
     * @param act
     */
    public void addAct(Activity act)
    {
        listAct.add(act);
    }

    /**
     * 移除act
     * @param act
     */
    public void delAct(Activity act)
    {
        listAct.remove(act);
    }

    /**
     * 清空act
     * @param
     */
    public void clearAct()
    {
        for(int i=0;i<listAct.size();i++)
        {
            listAct.get(i).finish();
        }
        listAct.clear();
    }
}
